﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TEAA
{
    public class DataTypeUtils
    {

        private static int booleanLength = sizeof(bool);
        private static int integerLength = sizeof(int);
        private static int decimalLength = sizeof(double);
        private static int characterLength = sizeof(char);
        private static int textLength = 255;
        private static int dateTimeLength = 8;

        public static int GetDataTypeLength(DataType type)
        {
            switch (type)
            {
                case DataType.Boolean:
                    return booleanLength;

                case DataType.Integer:
                    return integerLength;

                case DataType.Decimal:
                    return decimalLength;

                case DataType.Character:
                    return characterLength;

                case DataType.Text:
                    return textLength;

                case DataType.DateTime:
                    return dateTimeLength;
            }

            return 0;
        }


        public static DataType GetDataType(System.Type type)
        {
            
            if (type == typeof(int)) return DataType.Integer;
            if (type == typeof(bool)) return DataType.Boolean;
            if (type == typeof(decimal)) return DataType.Decimal;
            if (type == typeof(string)) return DataType.Text;
            if (type == typeof(char)) return DataType.Character;
            if (type == typeof(DateTime)) return DataType.DateTime;
            else return DataType.Text;
        }

        public static Type GetType(DataType type)
        {
            switch (type)
            {
                case DataType.Boolean:
                    return typeof(bool);

                case DataType.Integer:
                    return typeof(int);

                case DataType.Decimal:
                    return typeof(decimal);

                case DataType.Character:
                    return typeof(char);

                case DataType.Text:
                    return typeof(string);

                case DataType.DateTime:
                    return typeof(DateTime);
            }

            return typeof(string);
        }
    
    }
}
